using System;
using Drill.Extensibility;

namespace Drill.Core.Builders
{
	public class DrillBitBuilderDirector : IDrillBitBuilderDirector
	{
		private IDrillBitBuilder _builder;

		public void Initialize(IDrillBitBuilder builder)
		{
			if (null == builder)
			{
				throw new ArgumentNullException("builder");
			}
			_builder = builder;
		}

		public IDrillBit Build()
		{
			// The order of operations is very important in this method.
			_builder.BuildConfigurationSources();
			_builder.BuildInitializationContext();
			_builder.CreateDrillBit();
			return _builder.GetDrillBit();
		}
	}
}